// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides, prefer_const_literals_to_create_immutables, unnecessary_null_comparison, deprecated_member_use


import 'package:flutter/cupertino.dart';
import 'package:mybase/base/tool/empty/FFEmpty.dart';

class FFireBaseManager {
  // 单例公开访问点
  factory FFireBaseManager() => _sharedInstance();

  // 静态、同步、私有访问点
  static FFireBaseManager _sharedInstance() {
    return _instance;
  }

  // 静态私有成员，没有初始化
  static final FFireBaseManager _instance = FFireBaseManager._();

  // 私有构造函数
  FFireBaseManager._() {
    // 具体初始化代码
  }

  IFFGlobal? _global;

  setGlobal(IFFGlobal global){
    _global = global;
  }

  IFFGlobal? getGlobal(){
    return _global;
  }

  goPageBefore(String pageName) {
    if (!FFEmpty.stringIsEmpty(pageName)) {

      if (pageName.contains("#")) {
        pageName = pageName.split("#").first;
      }

      if (pageName.contains("-")) {
        pageName = pageName.split("-").first;
      }

      if (!FFEmpty.stringIsEmpty(pageName)) {
        _global?.goPage(pageName);
      }

    }
  }
  
}


abstract class IFFGlobal {
  ffDidChangeDependencies(var obj,BuildContext context);

  ffRemoveObserver(var obj);

  goPage(String pageName);
}
